//
// Created by 11510 on 2024/6/23.
//

#ifndef TEXTQUERY_QUERY_H
#define TEXTQUERY_QUERY_H

#include "WordQuery.h"
#include "TextQuery.h"
#include <iostream>
#include <memory>

class Query {
public:
    /*
     * 普通查询调用WordQuery()
     */
    Query(const std::string &s) : q(new WordQuery(s)) {}

    QueryResult eval(const TextQuery &t) const {
        return q->eval(t);
    }

    std::string rep() const {
        return q->rep();
    }

private:
    std::shared_ptr<QueryBase> q;

    Query(std::shared_ptr<QueryBase> query) : q(query) {}

    friend Query operator~(const Query &);

    friend Query operator|(const Query &, const Query &);

    friend Query operator&(const Query &, const Query &);
};

std::ostream &operator<<(std::ostream &os, const Query &query);


#endif //TEXTQUERY_QUERY_H
